using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{

    public partial class VICC_FUNCTIONS
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {

            switch (app.company)
            {
                case "YGR":
                case "YCC":
                default:
                    dwReturn["MANDANT"] = "00";
                    dwReturn["ROWNID"] = "0";
                    dwReturn["TYPE"] = "                    ";
                    dwReturn["NAMESPACE"] = "WPFExcelReport      ";
                    dwReturn["FULLNAME"] = "        ";
                    dwReturn["FILENAME"] = "            ";
                    dwReturn["DESCRIPTION"] = "        ";
                    break;
            }
        }

        public void InsertICC_FUNCTIONS(DataRow dwData, string ITXDBVERSION = "50.24")
        {

            or1 = OracleDB.CreateCommand();
            switch (ITXDBVERSION)
            {
                default:
                case "50.24":
                    or1.CommandText = "INSERT INTO ICC_FUNCTIONS ( MANDANT,ROWNID,TYPE,NAMESPACE,FULLNAME,FILENAME,DESCRIPTION)"
                    + " VALUES (:MANDANT:,:ROWNID:,:TYPE:,:NAMESPACE:,:FULLNAME:,:FILENAME:,:DESCRIPTION:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); 
                    break;
            } 
            Connect2Proxy(or1);
        }
        public void DeleteICC_FUNCTIONS(DataRow dwData, int option = 1)
        {
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 0:
                      or1.CommandText = "DELETE FROM ICC_FUNCTIONS"; 
                    break;
                case 1:
                     or1.CommandText = "DELETE FROM ICC_FUNCTIONS  WHERE ROWNID=:ROWNID:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); 
                    break;
            }
           
           
            Connect2Proxy(or1);
        }
        public DataSet QueryICC_FUNCTIONS(DataRow dwData, int option = 1)
        {

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM ICC_FUNCTIONS WHERE MANDANT=:MANDANT: AND ROWNID=:ROWNID:"; ;
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);

                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM ICC_FUNCTIONS WHERE MANDANT=:MANDANT: AND TYPE=:TYPE:"; ;
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                case -1:
                    or1.CommandText = "SELECT DISTINCT TYPE,DESCRIPTION,FULLNAME,FULLNAME AS KEY, DESCRIPTION AS DES FROM ICC_FUNCTIONS WHERE MANDANT=:MANDANT:"
                        +dwData["FULLNAME"].ToString()
                    +" ORDER BY DESCRIPTION";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                case 9999:
                    or1.CommandText = "SELECT * FROM ICC_FUNCTIONS WHERE MANDANT=:MANDANT:"; ;
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);

                    break;
                default:
                    break;
            }
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = "ICC_FUNCTIONS";
            return SResult;
        }
        public void UpdateICC_FUNCTIONS(DataRow dwData, string ITXDBVERSION = "50.24", int option = 1)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE ICC_FUNCTIONS SET MANDANT=:MANDANT:,ROWNID=:ROWNID:,TYPE=:TYPE:,NAMESPACE=:NAMESPACE:,FULLNAME=:FULLNAME:,FILENAME=:FILENAME:,DESCRIPTION=:DESCRIPTION:"
                + " WHERE ROWNID=:ROWNID:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
    }
}
